package file;

import java.io.File;
import java.io.IOException;

public class DeleteDemo {
    public static void main(String[] args) throws IOException {
        File file = new File("test.txt");
        File dir = new File("test");
        if(file.exists()){
            file.delete();
            System.out.println("文件已删除");
        }else{
//            file.delete();
            file.createNewFile();
            System.out.println("文件已创建");
        }
        System.out.println("-------");
        if(dir.exists()){
            dir.delete();
            System.out.println("目录已删除");
        }else{
            dir.mkdirs();
            System.out.println("目录已创建");
        }



    }
}
